/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.deployment.manager.search;

import br.com.deployment.daoImpl.CategoryDAOImpl;
import br.com.deployment.entities.Category;
import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

/**
 *
 * @author ely
 */
@ManagedBean
@SessionScoped
public class ManagerSearchCategory {

    @EJB
    CategoryDAOImpl categoryService;
    
    private List<Category> categorys;
    private Category category;

    public ManagerSearchCategory() {
    }
    
    public  List<Category> lstCategorys(){
        return categorys = categoryService.findAll();
    }
    
     public void redirect(String string, Category c) {
        try {
            FacesContext context = FacesContext.getCurrentInstance();
             category = c;
            context.getExternalContext().redirect(string);
        } catch (IOException ex) {
            Logger.getLogger(ManagerSearchCategory.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public Category getCategory() {
        return category;
    }

    public void setCategory(Category category) {
        this.category = category;
    }
     
}
